package character.action;

import com.jme3.export.InputCapsule;
import com.jme3.export.JmeExporter;
import com.jme3.export.JmeImporter;
import com.jme3.export.OutputCapsule;
import com.jme3.math.Vector3f;
import java.io.IOException;
import mygame.DefaultValues;
import character.AbstractCharacter;

public class MoveAction extends CharacterAction {
    protected float stopDistanceThreshold = DefaultValues.ACTION_MOVE_STOP_DISTANCE_THRESHOLD;

    public MoveAction() {}
    
    public MoveAction(Vector3f targetLocation) {
        this.targetLocation = targetLocation;
    }

    public MoveAction(Vector3f targetLocation, float stopDistanceThreshold) {
	this.targetLocation = targetLocation;
	this.stopDistanceThreshold = stopDistanceThreshold;
    }

    public float getStopDistanceThreshold() {
	return stopDistanceThreshold;
    }

    public void setStopDistanceThreshold(float stopDistanceThreshold) {
	this.stopDistanceThreshold = stopDistanceThreshold;
    }
    
    public Vector3f getTargetLocation() {
	return targetLocation;
    }

    public void setTargetLocation(Vector3f targetLocation) {
	this.targetLocation = targetLocation;
    }
    
    @Override
    protected boolean execute(AbstractCharacter performer) {
        return true;
    }
    
    @Override
    public void write(JmeExporter ex) throws IOException {
	super.write(ex);
	OutputCapsule capsule = ex.getCapsule(this);
        capsule.write(stopDistanceThreshold, "stopDistanceThreshold", DefaultValues.ACTION_MOVE_STOP_DISTANCE_THRESHOLD);
    }

    @Override
    public void read(JmeImporter im) throws IOException {
	super.read(im);
	InputCapsule capsule = im.getCapsule(this);
        stopDistanceThreshold = capsule.readFloat("stopDistanceThreshold", DefaultValues.ACTION_MOVE_STOP_DISTANCE_THRESHOLD);
    }
}
